updating oE values

values

include map.e 
namespace map 
public function values(map the_map, object keys = 0, object default_values = 0) 

returns values, without their keys, from a map.

Parameters:
  1. the_map : the map being queried
  2. keys : optional, key list of values to return.
  3. default_values : optional default values for keys list
Returns:

A sequence, of all values stored in the_map.

Comments:
  • The order of the values returned may not be the same as the putting order.
  • Duplicate values are not removed.
  • You use the keys parameter to return a specific set of values from the map. They are returned in the same order as the keys parameter. If no default_values is given and one is needed, 0 will be used.
  • If default_values is an atom, it represents the default value for all values in keys.
  • If default_values is a sequence, and its length is less than keys, then the last item in default_values is used for the rest of the keys.
Example 1:
map the_map_p 
the_map_p = new() 
put(the_map_p, 10, "ten") 
put(the_map_p, 20, "twenty") 
put(the_map_p, 30, "thirty") 
put(the_map_p, 40, "forty") 
 
sequence values 
values = values(the_map_p) 
-- values might be {"twenty","forty","ten","thirty"} 
-- or some other order 
Example 2:
map the_map_p 
the_map_p = new() 
put(the_map_p, 10, "ten") 
put(the_map_p, 20, "twenty") 
put(the_map_p, 30, "thirty") 
put(the_map_p, 40, "forty") 
 
sequence values 
values = values(the_map_p, { 10, 50, 30, 9000 }) 
-- values WILL be { "ten", 0, "thirty", 0 } 
values = values(the_map_p, { 10, 50, 30, 9000 }, {-1,-2,-3,-4}) 
-- values WILL be { "ten", -2, "thirty", -4 } 
See Also:

get, keys, pairs

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu